package com.cn.wanxi.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/news")
public class NewsServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        CompanyModel companyModel = new CompanyModel();
//        req.setAttribute("companyModel", companyModel);
//
//        NavModel navModel = new NavModel();//主要是用来取得数据
//        List<NavModel> navList = navModel.getNavList();
//        req.setAttribute("navList", navList);//这是导航数据
//        CommonIO commonIO=new CommonIO();
//        req.setAttribute("commonModelDto",commonIO.getFromCommon());

//        得到新闻信息
//        List<NewsModel> newsList = new ArrayList<>();
//        NewsModel newsModel = new NewsModel();//这一个的作用是用来取得数组的值
//        for (int i = 0; i < newsModel.newsHref.length; i++) {
//            NewsModel model = new NewsModel();//这个model用来封装每一个新闻数据
//            model.setTitle(newsModel.newsTitle[i]);
//            model.setHref(newsModel.newsHref[i]);
//            model.setCreateTime(newsModel.newsTime[i]);
//            newsList.add(model);
//        }

//        req.setAttribute("newsModelDto", new NewsIO().getFromNewsIO());
        req.getRequestDispatcher("/jsp/news.jsp").forward(req, resp);//将值转发到页面去
    }
}
